<?php

namespace backend\modules\trancfg\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\trancfg\models\Maintran;

/**
 * MaintranSearch represents the model behind the search form about `backend\modules\trancfg\models\Maintran`.
 */
class MaintranSearch extends Maintran
{
    public function rules()
    {
        return [
            [['MTID', 'MTNAME', 'SUBSYSID', 'TRANKIND', 'TRANMODE', 'TRANLVL', 'SYSTYPE', 'COMMODE', 'PKGMODE', 'MACCHK', 'TELLERCHK', 'BRCCHK', 'EXTFLAG1', 'EXTFLAG2', 'EXTFLAG3', 'EXTFLAG4', 'EXTFLAG5', 'EXTFLAG6', 'EXTITEM1', 'EXTITEM2', 'EXTITEM3', 'EXTITEM4', 'EXTITEM5', 'EXTITEM6'], 'safe'],
            [['TESTINFOLVL'], 'integer'],
        ];
    }

    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    public function search($params)
    {
        $query = Maintran::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        $query->andFilterWhere([
            'TESTINFOLVL' => $this->TESTINFOLVL,
        ]);

        $query->andFilterWhere(['like', 'MTID', $this->MTID])
            ->andFilterWhere(['like', 'MTNAME', $this->MTNAME])
            ->andFilterWhere(['like', 'SUBSYSID', $this->SUBSYSID])
            ->andFilterWhere(['like', 'TRANKIND', $this->TRANKIND])
            ->andFilterWhere(['like', 'TRANMODE', $this->TRANMODE])
            ->andFilterWhere(['like', 'TRANLVL', $this->TRANLVL])
            ->andFilterWhere(['like', 'SYSTYPE', $this->SYSTYPE])
            ->andFilterWhere(['like', 'COMMODE', $this->COMMODE])
            ->andFilterWhere(['like', 'PKGMODE', $this->PKGMODE])
            ->andFilterWhere(['like', 'MACCHK', $this->MACCHK])
            ->andFilterWhere(['like', 'TELLERCHK', $this->TELLERCHK])
            ->andFilterWhere(['like', 'BRCCHK', $this->BRCCHK])
            ->andFilterWhere(['like', 'EXTFLAG1', $this->EXTFLAG1])
            ->andFilterWhere(['like', 'EXTFLAG2', $this->EXTFLAG2])
            ->andFilterWhere(['like', 'EXTFLAG3', $this->EXTFLAG3])
            ->andFilterWhere(['like', 'EXTFLAG4', $this->EXTFLAG4])
            ->andFilterWhere(['like', 'EXTFLAG5', $this->EXTFLAG5])
            ->andFilterWhere(['like', 'EXTFLAG6', $this->EXTFLAG6])
            ->andFilterWhere(['like', 'EXTITEM1', $this->EXTITEM1])
            ->andFilterWhere(['like', 'EXTITEM2', $this->EXTITEM2])
            ->andFilterWhere(['like', 'EXTITEM3', $this->EXTITEM3])
            ->andFilterWhere(['like', 'EXTITEM4', $this->EXTITEM4])
            ->andFilterWhere(['like', 'EXTITEM5', $this->EXTITEM5])
            ->andFilterWhere(['like', 'EXTITEM6', $this->EXTITEM6]);

        return $dataProvider;
    }
}
